package shader;

/**
 * 
 * @author Jevgeni Krutov
 *
 */
public class Filter {

	private static final int NATURAL = 0;
	private static final int GREEN = 1;
	private static final int RED = -1;
	private static final int GRAY = 2;

	private int currentFilter = NATURAL;
	private float filterTransition = 0;

	public void setGreen() {
		currentFilter = GREEN;
	}

	public void setRed() {
		currentFilter = RED;
	}
	
	public void setGray() {
		currentFilter = GRAY;
	}

	public void reset() {
		currentFilter = NATURAL;
	}

	public void startTransition() {
		filterTransition = (float) currentFilter;
	}

	public void updateTransitionIfNeeded(long elapsedTime) {
		if (filterTransition > -0.2f && filterTransition < 0.2f) {
			filterTransition = 0f;
			return;
		}
		float diff = elapsedTime / 1700f;

		if (filterTransition > 0) {
			filterTransition -= diff;
		}
		if (filterTransition < 0) {
			filterTransition += diff;
		}
	}

	public int getCurrentFilter() {
		return currentFilter;
	}

	public float getFilterTransition() {
		return filterTransition;
	}

}
